﻿using System;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GUILibrary
{
    public class Backdrop
    {
        private Texture2D image;
        private Vector2 position;
        private string textureName;

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        public string TextureName
        {
            get { return textureName; }
            set { textureName = value; }
        }

        public void load(ContentManager cm)
        {
            image = cm.Load<Texture2D>(textureName);
        }

        public void Draw(SpriteBatch batch)
        {
            batch.Draw(image, Position, Color.White);
        }
    }

    public class BackdropContentReader : ContentTypeReader<Backdrop>
    {
        protected override Backdrop Read(ContentReader input, Backdrop existingInstance)
        {
            Backdrop backDrop = new Backdrop();

            backDrop.TextureName = input.ReadString();
            backDrop.Position = input.ReadVector2();

            backDrop.load(input.ContentManager);

            return backDrop;
        }
    }

    /*public class BackdropTypeWriter : ContentTypeWriter<Backdrop>
    {
        protected override void Write(ContentWriter output, Backdrop value)
        {
            output.Write(value.TextureName);
            output.Write(value.Position);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            // TODO: change this to the name of your ContentTypeReader
            // class which will be used to load this data.
            return typeof(BackdropContentReader).AssemblyQualifiedName;
        }
    }*/

}
